package com.stx.jeepay.payment.channel.alipay;

import com.stx.jeepay.core.entity.PayOrderEntity;
import com.stx.jeepay.core.enums.CS;
import com.stx.jeepay.payment.channel.AbstractPaymentService;
import com.stx.jeepay.payment.model.MchAppConfigContext;
import com.stx.jeepay.payment.rqrs.AbstractRS;
import com.stx.jeepay.payment.rqrs.payorder.UnifiedOrderRQ;
import com.stx.jeepay.payment.utils.PaywayUtil;
import org.springframework.stereotype.Service;

/**
 * 支付接口： 支付宝官方
 * 支付方式： 自适应
 */
@Service
public class AlipayPaymentService extends AbstractPaymentService {
    @Override
    public boolean isSupport(String wayCode) {
        return true;
    }

    @Override
    public String getIfCode() {
        return CS.IF_CODE.ALIPAY;
    }

    @Override
    public String preCheck(UnifiedOrderRQ rq, PayOrderEntity payOrder) {
        return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).preCheck(rq, payOrder);
    }


    @Override
    public AbstractRS pay(UnifiedOrderRQ rq, PayOrderEntity payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
        return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchAppConfigContext);
    }
}
